package com.example.houduan.service;

import com.example.houduan.domain.Wz_sb;
import com.example.houduan.domain.Wz_sbExample;
import com.example.houduan.mapper.Wz_sbMapper;
import com.example.houduan.rep.Repwzsf;
import com.example.houduan.resp.CommonResp;
import com.example.houduan.resp.Respwzsq;
import com.example.houduan.utils.CopyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Wzsbservice {
    @Autowired
    public Wz_sbMapper wz_sbMapper;
    public CommonResp add(Repwzsf repwzsf){
        CommonResp commonResp = new CommonResp();
        Wz_sb wz_sb= CopyUtil.copy(repwzsf,Wz_sb.class);
        int insert=wz_sbMapper.insert(wz_sb);
        if (insert==0){
            commonResp.setContent(false);
            return commonResp;
        }else{
            commonResp.setContent(true);
            return commonResp;
        }
    }
    public CommonResp fwwzsb(String uid){
        CommonResp commonResp = new CommonResp();
        Wz_sbExample wz_sbExample=new Wz_sbExample();
        Wz_sbExample.Criteria criteria= wz_sbExample.createCriteria();
        criteria.andUidEqualTo(uid).andDfdateIsNotNull();
        List<Wz_sb> wz_sbs=wz_sbMapper.selectByExample(wz_sbExample);
        List<Respwzsq> respwzsqs=CopyUtil.copyList(wz_sbs,Respwzsq.class);
        commonResp.setContent(respwzsqs);
        return commonResp;
    }
    public CommonResp fzwzsb(String uid){
        CommonResp commonResp = new CommonResp();
        Wz_sbExample wz_sbExample=new Wz_sbExample();
        Wz_sbExample.Criteria criteria= wz_sbExample.createCriteria();
        criteria.andUidEqualTo(uid).andDfdateIsNull();
        List<Wz_sb> wz_sbs=wz_sbMapper.selectByExample(wz_sbExample);
        List<Respwzsq> respwzsqs=CopyUtil.copyList(wz_sbs,Respwzsq.class);
        commonResp.setContent(respwzsqs);
        return commonResp;
    }

}
